﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using WebChart;
using System.Drawing;

public partial class Contents_Utilità_webChart : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        CreateChart();
    }//fm


		void CreateChart()
		{
			DataSet ds = CreateDataSet();

			ColumnChart chart = new ColumnChart();
			chart.MaxColumnWidth = 10;
			chart.Fill.Color = Color.FromArgb(50, Color.Red);
			chart.Shadow.Visible = true;
			chart.Legend = "Pri 0";

			ColumnChart chart1 = new ColumnChart();
			chart1.MaxColumnWidth = 10;
			chart1.Fill.Color = Color.FromArgb(50, Color.Yellow);
			chart1.Shadow.Visible = true;
			chart1.Legend = "Pri 1";

			LineChart chart5 = new LineChart();
			chart5.Line.Color = Color.Green;
			chart5.Fill.Color = Color.Green;
			chart5.LineMarker = new DiamondLineMarker(8, Color.Green, Color.Yellow);
			chart5.Legend = "Goal";

			foreach (DataRow row in ds.Tables[0].Rows)
			{
				chart.Data.Add(new ChartPoint(row["date"].ToString(), (int)row["pri0"]));
				chart1.Data.Add(new ChartPoint(row["date"].ToString(), (int)row["pri1"]));
				chart5.Data.Add(new ChartPoint(row["date"].ToString(), (int)row["goal"]));
			}

			chartControl1.Charts.Add(chart);
			chartControl1.Charts.Add(chart1);
			chartControl1.Charts.Add(chart5);
			chartControl1.RedrawChart();
		}
		/// <summary>
		/// Just generate some random data
		/// </summary>
		DataSet CreateDataSet()
		{
			DataSet ds = new DataSet();
			DataTable table = ds.Tables.Add("Table");
			table.Columns.Add("date");
			table.Columns.Add("pri0", typeof(int));
			table.Columns.Add("pri1", typeof(int));
			table.Columns.Add("pri2", typeof(int));
			table.Columns.Add("pri3", typeof(int));
			table.Columns.Add("total", typeof(int));
			table.Columns.Add("goal", typeof(int));
			Random rnd = new Random();
			for (int i = 0; i < 15; i++)
			{
				DataRow row = table.NewRow();
				row["date"] = DateTime.Now.AddDays(i).ToString("mm/dd");
				int pri0 = rnd.Next(200);
				int pri1 = rnd.Next(200);
				int pri2 = rnd.Next(200);
				int pri3 = rnd.Next(200);
				int sum = pri0 + pri1 + pri2 + pri3;
				int goal = rnd.Next(sum);

				row["pri0"] = pri0;
				row["pri1"] = pri1;
				row["pri2"] = pri2;
				row["pri3"] = pri3;
				row["total"] = sum;
				row["goal"] = goal;
				table.Rows.Add(row);
			}
			return ds;
		}
	 



}//fc
